package dagbok.data;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConexionDB {
	
	static String db = "dagbok";
	static String user = "root";
	static String pass = "root";
	static String url="jdbc:mysql://localhost/"+db;
	static String driver = "com.mysql.jdbc.Driver";
	
	private static ConexionDB conexion = null;
	
	private ConexionDB() {
		try {
			Class.forName(driver);
		} catch(Exception ex) {
			ex.printStackTrace();
		}
	}
	
	public Connection getConexion() throws SQLException {
		Connection conn = null;
		conn = DriverManager.getConnection(url,user,pass);
		return conn;
	}
	
	public static ConexionDB getInstancia() {
		if(conexion==null) {
			conexion = new ConexionDB();
		}			
		return conexion;
	}
	
	
}
